package com.lifeonwalden.dsg.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 节假日调整规则
 */
public enum HolidayAdjustRule {
    NIL(0),

    // 不作调整
    KEEP(1),

    // 调整为下一个非节假日
    MOVE_TO_NEXT(2),

    // 调整为前一个非节假日
    MOVE_TO_PREVIOUS(3);

    private static final Map<Integer, HolidayAdjustRule> valueMapping = new HashMap<Integer, HolidayAdjustRule>();
    private int value;

    HolidayAdjustRule(int value) {
        this.value = value;
    }

    static {
        HolidayAdjustRule[] enumArray = HolidayAdjustRule.values();
        for (HolidayAdjustRule enumItem : enumArray) {
            valueMapping.put(enumItem.getValue(), enumItem);
        }
    }

    public int getValue() {
        return value;
    }

    public static HolidayAdjustRule valueOf(int value) {
        HolidayAdjustRule enumItem = valueMapping.get(value);
        return null == enumItem ? NIL : enumItem;
    }
}